﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Eis51.CampanyCMS.Business.BaseInfoMng;
using Eis51.CampanyCMS.Model.Bus.QueryO;
using Eis51.CampanyCMS.Model;
using Eis51.CampanyCMS.Business.OnlineService;
using Eis51.CampanyCMS.Model.OnlineService;
using Eis51.CampanyCMS.Model.BaseInfoMng;

namespace Eis51.CampanyCMS.WebUI.Admin.MyUser
{
    public partial class UserList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ShowData();
            }
        }


        private void ShowData()
        { 
            ResUserQuery rq=new ResUserQuery() ;
            rq.Sellerid = AppContext.CurrentAdministrator.UserName;
            rq.BeginDate = string.IsNullOrEmpty(txtBeginDate.Text) ? "1901-01-01" : txtBeginDate.Text;
            rq.EndDate = string.IsNullOrEmpty(txtEndDate.Text) ? "2049-01-01" : txtEndDate.Text;
            rq.UserNoLike = txtUserName.Text;
            DataTable dt= ResUserBLL.GetInstance().Search(rq);

            dgNews.Data = dt;
            dgNews.DataBind();
        }

        protected void dgNews_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            

            if (e.Item.ItemType == ListItemType.AlternatingItem ||
              e.Item.ItemType == ListItemType.Item)
            {

            }
        }

        protected void dgNews_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            switch (e.CommandName)
            {
                case "Delete":

                    ResUserBLL.GetInstance().Delete(ResUserBLL.GetInstance().Get(new ResUser.Key(int.Parse(e.Item.Cells[0].Text))));
                    btnSearch_Click(null, null);
                    break;

            }
        }


        protected void btnSearch_Click(object sender, EventArgs e)
        {
            ShowData();
        }
    }
}
